---
title: Serialize imaging-import metadata into wire format
summary: Serializes a populated clsImageImport instance into the newline-delimited KEY=value wire format consumed by downstream imaging/xPresso integration.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-09-01
library: SAIF.Services.Imaging.Import
reference_type: embedded
operation_id: op-img-001-serialize-wire-format
trigger: Caller invokes clsImageImport.ToString()
---

# Serialize imaging-import metadata into wire format

Serializes the populated property values on a `clsImageImport` instance into a newline-delimited `KEY=value` wire-format block for downstream imaging/xPresso consumption.

| Field | Value |
| --- | --- |
| **Operation ID** | op-img-001-serialize-wire-format |
| **Trigger** | Caller invokes `clsImageImport.ToString()` |
| **Inputs** | Populated property values on the `clsImageImport` instance (claim, policy, agency/group, legal, task, imaging fields) |
| **Outputs** | Newline-delimited (`vbCrLf`) `KEY=value` wire-format block |
| **Primary components** | `clsImageImport.ToString()` |
| **Entry point** | `SAIF.Services.Imaging.Import/clsImageImport.vb` |

## Steps

1. Append fixed unconditional identifier/text fields (`BATID`, `CLAIMID`, `CLAIMNUM`, `CommentText`, `CreateUser`, `DiscoveryFlag`, `DisplayField1..3`) — [BR-IMG-010](../business-rules.md#br-img-010-wire-format-contract-key-set-and-order).
2. Emit `DocumentDate` (`MM-dd-yyyy`) only if strictly within `(Date.MinValue, Date.MaxValue)`, else blank — [BR-IMG-001](../business-rules.md#br-img-001-date-field-emission).
3. Emit `DocumentDateDays` only if greater than zero, else blank — [BR-IMG-002](../business-rules.md#br-img-002-document-date-tolerance-window-emission).
4. Append unconditional imaging classification fields (`ImageFileCode`, `ImageCategoryCode`, `ImageDocumentTypeCode`, `ImageDeleteFlag`, `ImageIndexFlag`). `ImageFileCode` and `ImageIndexFlag` receive non-empty defaults at construction per [BR-IMG-008](../business-rules.md#br-img-008-construction-time-defaults); `ImageCategoryCode`, `ImageDocumentTypeCode`, and `ImageDeleteFlag` default to empty and are populated by the caller, with `ImageDocumentTypeCode` values expected to come from the advisory-only vocabulary in [BR-IMG-009](../business-rules.md#br-img-009-onbase-document-type-vocabulary). The full key set's presence and order is fixed per [BR-IMG-010](../business-rules.md#br-img-010-wire-format-contract-key-set-and-order).
5. Emit `ImageSeqNum` only if greater than zero, else blank — [BR-IMG-003](../business-rules.md#br-img-003-image-sequence-number-emission).
6. Emit `NPages` only if greater than zero, else blank — [BR-IMG-004](../business-rules.md#br-img-004-page-count-emission).
7. Emit `PolicyNum` only if greater than zero, else blank — [BR-IMG-005](../business-rules.md#br-img-005-policy-number-emission).
8. Emit `ReceivedDate`, using the same range rule as step 2 — [BR-IMG-001](../business-rules.md#br-img-001-date-field-emission).
9. Append unconditional fields (`SLevel`, `ImageDocumentNameCode`, `ExternalViewCode`, `SystemGeneratedFlag`, `AgencyID`, `ProducerID`, `GroupAssociationCode`, `Spec`, `TaskCategory`) — [BR-IMG-010](../business-rules.md#br-img-010-wire-format-contract-key-set-and-order).
10. Emit `TaskDate`, using the same range rule as step 2 — [BR-IMG-001](../business-rules.md#br-img-001-date-field-emission).
11. Append unconditional fields (`TaskMailIDList`, `TaskPriority`, `TaskSecurity`, `TaskText`, `PolicyAccount`, `PolicySecuredFlag`) — [BR-IMG-010](../business-rules.md#br-img-010-wire-format-contract-key-set-and-order).
12. Emit `AffiliationId` only if greater than zero, else blank — [BR-IMG-006](../business-rules.md#br-img-006-affiliation-identifier-emission).
13. Emit `LegalCaseId` only if greater than zero, else blank — [BR-IMG-007](../business-rules.md#br-img-007-legal-case-identifier-emission).
14. Append final unconditional legal fields (`LegalCaseNum`, `LegalCopyToClaimFlag`, `LegalDistributionFlag`) — [BR-IMG-010](../business-rules.md#br-img-010-wire-format-contract-key-set-and-order).
15. Return the accumulated `StringBuilder` content as the wire-format string.

## Process flow

The following diagram visualizes this operation's control flow, with one decision node per conditional emission rule ([BR-IMG-001](../business-rules.md#br-img-001-date-field-emission) through [BR-IMG-007](../business-rules.md#br-img-007-legal-case-identifier-emission)) and unconditional field appends collapsed into single nodes between decisions.

```mermaid
flowchart TD
	Start(["Caller invokes<br>ToString()"]) --> A["Append fixed<br>identifier fields"]
	A --> B{"DocumentDate<br>in range?"}
	B -->|Yes| B1["Emit DocumentDate<br>MM-dd-yyyy"]
	B -->|No| B2["Emit DocumentDate<br>blank"]
	B1 --> C{"DocumentDateDays<br>> 0?"}
	B2 --> C
	C -->|Yes| C1["Emit<br>DocumentDateDays"]
	C -->|No| C2["Emit blank"]
	C1 --> D["Append imaging<br>classification fields"]
	C2 --> D
	D --> E{"ImageSeqNum<br>> 0?"}
	E -->|Yes| E1["Emit ImageSeqNum"]
	E -->|No| E2["Emit blank"]
	E1 --> F{"NPages<br>> 0?"}
	E2 --> F
	F -->|Yes| F1["Emit NPages"]
	F -->|No| F2["Emit blank"]
	F1 --> G{"PolicyNum<br>> 0?"}
	F2 --> G
	G -->|Yes| G1["Emit PolicyNum"]
	G -->|No| G2["Emit blank"]
	G1 --> H{"ReceivedDate<br>in range?"}
	G2 --> H
	H -->|Yes| H1["Emit ReceivedDate"]
	H -->|No| H2["Emit blank"]
	H1 --> I["Append SLevel..<br>TaskCategory fields"]
	H2 --> I
	I --> J{"TaskDate<br>in range?"}
	J -->|Yes| J1["Emit TaskDate"]
	J -->|No| J2["Emit blank"]
	J1 --> K["Append TaskMailIDList..<br>PolicySecuredFlag fields"]
	J2 --> K
	K --> L{"AffiliationId<br>> 0?"}
	L -->|Yes| L1["Emit AffiliationId"]
	L -->|No| L2["Emit blank"]
	L1 --> M{"LegalCaseId<br>> 0?"}
	L2 --> M
	M -->|Yes| M1["Emit LegalCaseId"]
	M -->|No| M2["Emit blank"]
	M1 --> N["Append final<br>legal fields"]
	M2 --> N
	N --> End(["Return wire-format<br>string"])
```

## Failure and edge-case behavior
- No try/catch blocks, validation, or null guards exist in `ToString()`; a `Nothing`-valued string property appends as empty text without raising an exception.
- The fixed key set ([BR-IMG-010](../business-rules.md#br-img-010-wire-format-contract-key-set-and-order)) still emits values that fall outside the advisory-only OnBase vocabulary ([BR-IMG-009](../business-rules.md#br-img-009-onbase-document-type-vocabulary)) as-is, since assignment is never validated against those constants.
- Callers must construct the instance via `New clsImageImport` to receive the [BR-IMG-008](../business-rules.md#br-img-008-construction-time-defaults) construction-time defaults before populating and serializing it.*

## Related documentation
- [Index](../index.md)
- [Overview](../overview.md)
- [Architecture](../architecture.md)
- [Dependencies](../dependencies.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [API reference](../api/index.md)

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- `SAIF.Services.Imaging.Import/clsImageImport.vb`
